<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset = UTF-8" />
        <link href="public/css.css" rel="stylesheet" type="text/css" />
        <title>Facebook</title>
    </head>

    <body>
        <div class="chung">
            <?php
            require_once './model/works.php';
            $keyword = new Works();
            $keyword->table_name = "works";
            ?>
            <?php
            if (!isset($_GET["page"]))
                $page = 1;
            else
                $page = $_GET["page"];

            $total = $keyword->countWords();
            ?>
            <div class="hinh"></div>
            <h2>Facebook</h2>
            <div class="menu">
                <ul>
                    <li><a rel="home" href="http://facebook.com/" title="Nghe Nhạc" class="logo">Facebook</a></li>
                    <li><a rel="home" href="http://haivl.com/" title="Nghe Nhạc" class="logo">Hài vl</a></li>
                    <li><a rel="home" href="http://forum.vietdesigner.net/" title="Nghe Nhạc" class="logo">VietDesigner</a></li>
                    <li><a rel="home" href="http://www.nhaccuatui.com/" title="Nghe Nhạc" class="logo">Music</a></li>
                    <li> <input type="text" id="type"/><input type="button" value="Search" id="ty"></li>
                </ul>
                <div class="thanh"></div>

            </div>


            <table>
                <tr>
                    <td>Username: </td>
                    <td><input type="text" name="username" id="name"></td>
                </tr>
                <tr>
                    <td>Password: </td>
                    <td><input type="password" name="password" id="password">
                </tr>
            </table>
            <input type="submit" name="submit" value="Enter"></p>
            </form>

            <?php
            require_once './data/users.php';
            if (isset($_POST['submit'])) {
                $username = $_POST['username'];
                $password = $_POST['password'];
                $Ok = FALSE;
                $index = -1;
                for ($i = 0; $i < count($users); $i++) {
                    if ((strcmp($users[$i]['username'], $username) == 0) &&
                            (strcmp($users[$i]['password'], $password) == 0)) {
                        $Ok = TRUE;
                        $index = $i;
                    }
                }
                if ($Ok) {
                    header("Location: http://localhost/lcnguyen-web2/public/index.php ?uid=" . $users[$index]['id']);
                } else {
                    echo "Đăng nhập thất bại";
                }
            }
            ?>
            <div class="cuoi">Nguyên C12TDT</div>

        </div>
    </body>
</html>